package com.kaisa.activity.ui;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.kaisa.activity.BaseApp;
import com.kaisa.activity.R;

import butterknife.Bind;
import butterknife.ButterKnife;


public class LifeActivity extends AppCompatActivity implements View.OnClickListener {
    @Bind(R.id.top_back)
    ImageView topBack;
    @Bind(R.id.top_title)
    TextView topTitle;
    @Bind(R.id.top_share)
    ImageView topShare;
    @Bind(R.id.top_web)
    WebView topWeb;
    private String title;
    private String url;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.hometop_main);
        ButterKnife.bind(this);
        Intent intent = getIntent();
         title = intent.getStringExtra("title");
         url = intent.getStringExtra("url");
        topTitle.setText(title.split(" ")[0]);
        topWeb.getSettings().setJavaScriptEnabled(true);
        topWeb.loadUrl(url);
        topBack.setOnClickListener(this);
        topShare.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.top_back:
                this.finish();
                break;
            case R.id.top_share:
                BaseApp.getInstance().showShare(title,url);
                break;
        }
    }
}
